Imports System.Collections.Generic

Partial Class WebForm_SelfManageEnlistment_AddEnlist
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.SqlDataSource1.SelectParameters("VolunteerID").DefaultValue = Context.User.Identity.Name
    End Sub

    Protected Sub gv_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv.RowCommand
        If e.CommandArgument = "btnGetIn" Then
            Dim dat As New clsData
            Dim sql As New MyStringBuilder

            Dim CheckCount As Integer = 0
            Dim chkGetIn As CheckBox
            Dim hideEnlistID As HiddenField
            For i As Integer = 0 To gv.Rows.Count - 1
                chkGetIn = TryCast(Me.gv.Rows(i).FindControl("chkGetIn"), CheckBox)
                hideEnlistID = TryCast(Me.gv.Rows(i).FindControl("hideEnlistID"), HiddenField)
                If Not chkGetIn Is Nothing AndAlso chkGetIn.Checked Then
                    CheckCount += 1
                    sql.AppendFormat("insert EnlistRecordApplication select ")
                    sql.AppendFormat("'{0}' ", hideEnlistID.Value)
                    sql.AppendFormat(",'{0}' ", Context.User.Identity.Name)
                    sql.AppendFormat(",{0} ", "null")
                    sql.AppendFormat(",'WA'")
                    sql.AppendFormat(",{0} ", "getdate()")
                    sql.AppendFormat(",'{0}' ", Context.User.Identity.Name)
                End If
            Next
            If CheckCount = 0 Then
                MyObj.ShowMessage(Me.GetLocalResourceObject("MustCheck"))
            Else
                Using scope As New Transactions.TransactionScope
                    dat.AccData(sql.ToString(), Nothing, Data.CommandType.Text)
                    scope.Complete()
                End Using
                Me.gv.DataBind()
                RaiseEvent Finish(Me, New EventArgs)
            End If
        End If
    End Sub

    Public Event Finish(ByVal sender As Object, ByVal e As System.EventArgs)
End Class